home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / mg2a_src.zip / SPAWN.C < prev    next >
C/C++ Source or Header  |  1991-02-16  |  856b  |  44 lines

  1. /*
  2.  * Name:    Mg 2a
  3.  *        Spawn CLI for MSDOS (TurboC 1.5)
  4.  *
  5.  */
  6. #include    "def.h"
  7. #include    <process.h>
  8.  
  9. extern    char    *getenv();
  10.  
  11. /*
  12.  * On MSDOS, we got no job control like system V, so always
  13.  * run a subshell. Bound to "C-C", and used
  14.  * as a subcommand by "C-Z". (daveb)
  15.  *
  16.  * Returns 0 if the shell executed OK, something else if
  17.  * we couldn't start shell or it exited badly.
  18.  */
  19. spawncli(f, n, k)
  20. {
  21.     char *comspec;
  22.     int        errp = FALSE;
  23.  
  24.     ttcolor(CTEXT);
  25.     ttnowindow();
  26.     ttmove(nrow-1, 0);
  27.     if (epresf != FALSE) {
  28.         tteeol();
  29.         epresf = FALSE;
  30.     }
  31.     ttclose();
  32.     sgarbf = TRUE;                /* Force repaint.    */
  33.     if ((comspec = getenv("COMSPEC")) == NULL)
  34.         errp = -1;
  35.     else
  36.         errp = spawnl(P_WAIT, comspec, "COMMAND.COM", (char *)NULL);
  37.  
  38.     ttopen();
  39.     if(errp == -1)
  40.         ewprintf("Failed to create process");
  41.  
  42.     return ( errp );
  43. }
  44.